package duhosdebuggolok;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ApplePainter implements Painter {

	private static BufferedImage appleImage = null;
	private Apple apple;
	
	public ApplePainter(Apple a) {
		apple = a;
		if (appleImage == null)
			loadImage();
	}
	
	private static void loadImage() {
		try {
			appleImage = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\alma.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public boolean paint(Graphics2D g){
		Point coord = apple.getCoord();
		int radius = apple.getRadius();
		boolean eaten = apple.isEaten();
		double scale = 3;
		//AffineTransform affineTransform = new AffineTransform();
		Point c = GamePanel.calculate(coord);
		//affineTransform.translate((c.x-2), (c.y + 5));
		//affineTransform.scale(scale, scale);
		g.drawImage(appleImage, c.x, c.y, null);
		if (eaten)
			return false;
		return true;
	}

}
